// vue.config.js

// 是否为生产环境
const isProduction = process.env.NODE_ENV !== "development";

// 本地环境是否需要使用cdn
const devNeedCdn = false;
// cdn链接
const cdn = {
  // cdn：模块名称和模块作用域命名（对应window里面挂载的变量名称）
  externals: {
    vue: "Vue",
    vuex: "Vuex",
    "vue-router": "VueRouter",
    "element-ui": "ELEMENT",
  //  axios: "axios"
  },
  // cdn的css链接
  css: [
    // "https://cdn.bootcss.com/nprogress/0.2.0/nprogress.min.css",
    "https://unpkg.com/element-ui/lib/theme-chalk/index.css"
    // "src/assets/css/index.css"
  ],
  // cdn的js链接
  js: [
    "https://cdn.jsdelivr.net/npm/vue@2.6.14",
    "https://cdn.jsdelivr.net/npm/vuex@3.4.0",
    "https://cdn.jsdelivr.net/npm/vue-router@3.2.0",
    "https://cdn.jsdelivr.net/npm/echarts@5.0.5",
    // "https://unpkg.com/axios@0.21.1/dist/axios.min.js",
    "https://unpkg.com/element-ui@2.15.3/lib/index.js"
  ]
};
module.exports = {
  productionSourceMap: false,
  chainWebpack: (config) => {
    config.plugin("html").tap((args) => {
      args[0].title = "易捷税大师";
      if (isProduction || devNeedCdn) args[0].cdn = cdn;
      return args;
    });

  },
  configureWebpack: config => {
    // 用cdn方式引入，则构建时要忽略相关资源
    if (isProduction || devNeedCdn) config.externals = cdn.externals;
  }
};
// module.exports = {
//   configureWebpack: (config) => {
//     if (process.env.NODE_ENV === "production") {
//       // 为生产环境修改配置...
//     } else {
//       // 为开发环境修改配置...
//     }
//   },
// };
